<template>
    <div class="main-container">
        <zl-table ref="fileTable" :request-fun="this.api.system.getFileList">
            <zl-table-column label="名称" prop="oldName" min-width="70px"/>
            <zl-table-column label="文件" min-width="200px">
                <template slot-scope="scope">
                    <el-link :href="scope.row.url" target="_blank">
                        {{ scope.row.url }}
                    </el-link>
                </template>
            </zl-table-column>
            <zl-table-column label="上传用户" min-width="30px">
                <template slot-scope="scope">
                    {{ scope.row.adminName ? scope.row.adminName : '无' }}
                </template>
            </zl-table-column>
            <zl-table-column label="创建时间" prop="createDate" min-width="50px"/>
            <zl-table-column label="使用状态" min-width="30px">
                <template slot-scope="scope">
                    <i :class="scope.row.relatedNum>0?'el-icon-success':'el-icon-error'"
                       :style="{'color':scope.row.relatedNum>0?'#1dc700':'red','font-size': '20px'}"></i>
                </template>
            </zl-table-column>
            <el-table-column
                    label="操作">
                <template slot-scope="scope">
                    <el-button @click="delFile(scope.row.id)">删除</el-button>
                </template>
            </el-table-column>
        </zl-table>
    </div>
</template>

<script>
import {exportData,handleFileChange} from "@/utils/fileUtil";
export default {
    name: "SysFile",
    data() {
        return {
            //接口api
            api: this.$store.getters.app.api,
            exportData:null,
        }
    },
    created() {
        this.exportData = exportData
    },
    methods: {
        async delFile(item) {
            await this.$confirm("你确定要删除吗？", "删除提示", {
                confirmButtonText: "确定",
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                await this.api.system.delFile({id: item})
                this.$refs.fileTable.refresh()
            })
        }
    }
}
</script>

<style scoped>

</style>